import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:niuren_demo/configs/Colors_util.dart';
import 'package:niuren_demo/model/NrAccountItem_model.dart';
import 'package:niuren_demo/view/dynamic_page/NrAccountItem.dart';
import 'package:niuren_demo/view/dynamic_page/NrAccountTitle.dart';
import 'package:niuren_demo/view/text/text_style.dart';

class NrAccountPage extends StatefulWidget {
  @override
  _NrAccountPageState createState() => _NrAccountPageState();
}

class _NrAccountPageState extends State<NrAccountPage> {
  List NrAccountDataSoure = [
    {
      "imageurl":
          "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fb-ssl.duitang.com%2Fuploads%2Fitem%2F201808%2F15%2F20180815112431_keyzi.thumb.700_0.jpeg&refer=http%3A%2F%2Fb-ssl.duitang.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1617851642&t=7b6a7c66ce19ae61adcdf25c8c3b8856",
      "title": "牛了吧唧的牛人",
      "tip": "OKEX/永续合约金本位BTC/USDT牛人",
      "followInt": 87,
      "profit": 98.76,
    },
    {
      "imageurl":
          "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fb-ssl.duitang.com%2Fuploads%2Fitem%2F201808%2F15%2F20180815112431_keyzi.thumb.700_0.jpeg&refer=http%3A%2F%2Fb-ssl.duitang.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1617851642&t=7b6a7c66ce19ae61adcdf25c8c3b8856",
      "title": "牛了吧唧的牛人",
      "tip": "HOUBI/永续合约金本位BTC/USD牛人",
      "followInt": 146,
      "profit": 80.90,
    },
    {
      "imageurl":
          "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fb-ssl.duitang.com%2Fuploads%2Fitem%2F201808%2F15%2F20180815112431_keyzi.thumb.700_0.jpeg&refer=http%3A%2F%2Fb-ssl.duitang.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1617851642&t=7b6a7c66ce19ae61adcdf25c8c3b8856",
      "title": "牛了吧唧的牛人",
      "tip": "BINACE/永续合约金本位BTC/USDT牛人",
      "followInt": 87,
      "profit": 98.76,
    },
  ];

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Container(
        padding: EdgeInsets.symmetric(horizontal: 5),
        child: Row(
          children: [
            Expanded(
              child: GridView.builder(
                physics: NeverScrollableScrollPhysics(),
                gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
                    crossAxisCount: 2, //横轴三个子widget
                    childAspectRatio: 1.2 //宽高比为1时，子widget
                ),
                itemBuilder: (context, index) {
                  if(index == 0){
                    return NrAccountTitle();
                  }
                  return NrAccountItem(
                    dataModel: NrAccountItem_Model.fromJson(NrAccountDataSoure[index-1]),
                  );
                },
                itemCount: NrAccountDataSoure.length+1,
              ),
            ),
          ],
        ),
      ),
    );
  }
}
